#pragma once

#include "IXAutoBuffer.h"
#include "XBaseObjImpl.h"

class CXAutoBufferImpl : public CXBaseObjImpl<IXAutoBuffer>
{
    typedef CXBaseObjImpl<IXAutoBuffer> superclass;
    DEF_SKIN_CLASS_SINGLE_INTF(CXAutoBufferImpl,
        superclass,
        gs_strGuidXSkin,
        IXAutoBuffer,
        0);

public:
    CXAutoBufferImpl();
    virtual ~CXAutoBufferImpl();

public:
    // IXAutoBuffer
    virtual HRESULT STDMETHODCALLTYPE   GetBuffer(OUT void** pBuffer);
    virtual HRESULT STDMETHODCALLTYPE   GetBuffer(OUT void** pBuffer, IN DWORD dwMinSize);
    virtual HRESULT STDMETHODCALLTYPE   GetSize(OUT DWORD* pdwSize);

public:
    virtual void    STDMETHODCALLTYPE   OnFinalRelease();

protected:
    void        ReleaseData();

protected:
	LPVOID      m_pData;
	DWORD       m_dwSize;
	DWORD       m_dwRealSize;
};

